﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using CentaLine.Model;
using CentaLine.Repository;

namespace CentaLine.Site.Controllers
{
    public class BackRestoreController : BaseController
    {

        private VitualPhoneManager vm = null;
        public BackRestoreController()
        {
            vm = new VitualPhoneManager();
        }

        public ActionResult Index()
        {
            ViewBag.Message = "测试视图";
            return View();
        }

        // GET: /BackRestore/GetBackUpInfoList
        public ActionResult GetBackUpInfoList()
        {
            var result = vm.GetBackUpInfoList();
            return Json(result,JsonRequestBehavior.AllowGet);
        }

        // GET: /BackRestore/RestoreRemoteData
        public ActionResult RestoreRemoteData(string backTime)
        {
            var res = new CommResult();
            DateTime realDate;
            if (!DateTime.TryParse(backTime,out realDate))
            {
                res.Result = false;
                res.Exception = "时间格式不正确";
            }
            else
            {
                res = vm.Restoredialnumber(realDate);
                vm.ClearEShopApply(DateTime.Now);//同时清空当前月份申请
            }
             return Json(res, JsonRequestBehavior.AllowGet);
        }


        // GET: /BackRestore/RestoreRemoteData
        public ActionResult BackRemoteData()
        {
            var res = vm.BackUpdialnumber();//备份远程数据
            return Json(res, JsonRequestBehavior.AllowGet);
        }


        // GET: /BackRestore/RestoreRemoteData
        public ActionResult AutoSign()
        {
            var res  = vm.AutoAssign();
            return Json(res, JsonRequestBehavior.AllowGet);
        }
    }
}
